package com.uestc.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;


public class HBaseProperties {
	private static Properties properties;
	static {
		init();
	}

	public static void init() {
		properties = new Properties();
		String pathString = HBaseProperties.class.getResource("/").getPath();
		pathString = pathString.substring(0, pathString.lastIndexOf("classes"))
				+ "conf/hbase.properties";
		FileInputStream fs = null;
		try {
			fs = new FileInputStream(pathString);
			properties.load(fs);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			properties = null;
		} catch (IOException e) {
			e.printStackTrace();
			properties = null;
		} finally {
			try {
				if(fs != null)
					fs.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public static String getValue(String key) {
		if (properties == null){
			return null;
		}
		return properties.getProperty(key);
	}
}
